package com.erdos.upc.dao.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.erdos.common.dao.IBatisGenericDaoImpl;
import com.erdos.upc.dao.PrivilegeDao;
import com.erdos.upc.entity.Privilege;

public class PrivilegeDaoImpl extends IBatisGenericDaoImpl<Privilege> implements PrivilegeDao {

	/**
	 * 删除角色与权限的关联
	 * @param privilegeId
	 */
	
	public void deletePrivilegeRole(Long privilegeId) {
		this.getSqlMapClientTemplate().delete("Privilege.deletePrivilegeRole", privilegeId);
	}

	@SuppressWarnings("unchecked")
	public List<Privilege> findAllPrivilegeByUserSid(Long userSid) {
		return this.getSqlMapClientTemplate().queryForList("Privilege.findAllPrivilegeByUserSid", userSid);
	}

//    public void deleteRoleR2Privilege(Long roleSid,Long privilegeSid) {
//        Map<String,Long> param = new HashMap<String,Long>();
//        param.put("roleSid", roleSid);
//        param.put("privilegeSid", privilegeSid);
//          this.getSqlMapClientTemplate().delete("Privilege.deleteRoleR2Privilege",param);
//    }

    public Privilege findByRptId(String rptId) {
        return (Privilege)getSqlMapClientTemplate().queryForObject("Privilege.findByRptId",rptId);
    }

    public void deleteRoleR2Privilege(Long privilegeSid) {
        Map<String,Long> param = new HashMap<String,Long>();
        param.put("privilegeSid", privilegeSid);
        getSqlMapClientTemplate().delete("Privilege.deleteRoleR2Privilege",param);
        
    }

//    @SuppressWarnings("unchecked")
//    public List<Privilege> findByRptId(String rptId) {
//        return this.getSqlMapClientTemplate().queryForList("Privilege.findByRptId",rptId);
//    }

}
